<template>
	<view class="imgcover"><jy-image class="imgfull" mode="scaleToFill" :src="src" placeholder="../../static/walcome.png" @loadCompleted="loadCompleted"></jy-image></view>
</template>

<script>
import {
		getImageCache
	} from '../../common/saveimg.js';	
export default {
	data() {
		return {
			src: '../../static/walcome.png',
			isload: false,
			extype: ''
		};
	},
	onLoad() {
		var that = this;
		
		try {
			const value = uni.getStorageSync('lang_key');
			//console.log("app onlaunch",value);
			if (value) {
				that.$i18n.locale = value;
				if (value == 'cn') {
					that.lolang = 'CN';
				}
				if (value == 'uy') {
					that.lolang = 'UG';
				}
				if (value == 'kz') {
					that.lolang = 'KAZ';
				}
			}else{
				
			}
		} catch (e) {
			// error
			
		}

		//获取版本信息

		//判断微信登录

		// #ifdef MP
		that.tanchutiao();
		// #endif
		//
		//#ifdef APP-PLUS
		//that.copys();

		// #endif
		
		
		
		
		
		uni.getNetworkType({
		    success: function (res) {
		        console.log(res.networkType);//网络类型 wifi、2g、3g、4g、ethernet、unknown、none
		        if(res.networkType === "none"){
		            console.log("当前无网络");
					
					var date = new Date();
					var hour = date.getDate();
					
					var mdnum = date.getFullYear()+date.getMonth()+date.getDate();
					var bannerurl = "https://tongyongjiakao-1307163845.cos.ap-shanghai.myqcloud.com/guanggao/00.png";
					var bannersave = getImageCache(bannerurl,mdnum);
					console.log("有网络",bannersave);
					if(bannersave == undefined){
						that.src = '../../static/walcome.png';
					}else{
						that.src = bannersave;
					}
		        }else{
					var date = new Date();
					var hour = date.getDate();
					
					var mdnum = date.getFullYear()+date.getMonth()+date.getDate();
					var bannerurl = "https://tongyongjiakao-1307163845.cos.ap-shanghai.myqcloud.com/guanggao/00.png";
					var bannersave = getImageCache(bannerurl,mdnum);
		            console.log("有网络",bannersave);
					if(bannersave == undefined){
						that.src = "https://tongyongjiakao-1307163845.cos.ap-shanghai.myqcloud.com/guanggao/00.png";
					}else{
						that.src = bannersave;
					}
					
					//有网络时检查用户资格
		        }
		    }
		});
		
		
		
		
		
		

		//检测是否联网？ 如果联网
		
		//1.用户状态是否生效
		//2.数据是否复制过？  如果复制过 有没有更新，如果有更新 进行更新


		//弹出框
		//#ifdef APP-PLUS
		//that.copys();
		
		that.tanchutiao();
		

		// #endif

		// //密码测试
		// let strs = this.newtools.fun2();
		// console.log(this.newtools.fun1(strs));
		// let jsonstr = this.newtools.fun1(strs);
		// //加密测试
		// //加密值
		// //let e = this.AES.encrypt('https://img9.doubanio.com/view/photo/l_ratio_poster/public/p2654242565.jpg','1jhtconstrj2age3','_tongyongjiakao_')
		// let e = this.AES.encrypt('ادام بار، زات جوق','1jhtconstrj2age3','_tongyongjiakao_')
		// console.log(e);
		// //解密值
		// let s = this.AES.decrypt(e,jsonstr,'_tongyongjiakao_')
		// console.log(s);
	},
	methods: {
		tanchutiao(){
			setTimeout(() => {
				uni.getStorage({
					key: 'cart_type',
					success: function(res) {
						uni.getStorage({
							key: 'exam_type',
							success: function(res) {
								console.log(res, '=====');
								console.log(res.data);
								uni.getStorage({
									key: 'user_infos',
									success: function(rest) {
										console.log(rest, '=====');
										var userstatus = rest.data.userstatus;
										if (userstatus > 0) {
											//判断时间是否到？
											let timestamp = new Date().getTime();
											let jieshuriqi = rest.data.jieshuriqi;
											console.log('日期比较', timestamp, jieshuriqi);
											if (jieshuriqi > timestamp) {
												if (res.data == 'zigezheng') {
													console.log('tiao zhuan le ');
													uni.reLaunch({
														url: 'qualification'
													});
												} else {
													uni.reLaunch({
														url: './index'
													});
												}
											} else {
												uni.reLaunch({
													// url: '../activation/activeModal/activeModal',
													url: './index'
												});
											}
										} else {
											uni.reLaunch({
												// url: '../activation/activeModal/activeModal',
												url: './index'
											});
										}
									},
									fail() {
										uni.reLaunch({
											url: '../setting/setting'
										});
									}
								});
							},
							fail: function(e) {
								console.log('err=', e);
								uni.reLaunch({
									url: '../setting/setting'
								});
							}
						});
					},
					fail() {
						console.log('5555555555555');
						uni.reLaunch({
							url: '../setting/setting'
						});
					}
				});
			}, 3000);
		},
		loadCompleted(e) {
			//加载完毕
			// setTimeout(() => {
			// 	uni.getStorage({
			// 		key: 'cart_type',
			// 		success: function(res) {
			// 			uni.getStorage({
			// 				key: 'exam_type',
			// 				success: function(res) {
			// 					console.log(res, '=====');
			// 					console.log(res.data);
			// 					if (res.data == 'zigezheng') {
			// 						console.log('tiao zhuan le ');
			// 						uni.reLaunch({
			// 							url: 'qualification'
			// 						});
			// 					} else {
			// 						uni.reLaunch({
			// 							url: './index'
			// 						});
			// 					}
			// 				},
			// 				fail: function(e) {
			// 					console.log('err=', e);
			// 					uni.reLaunch({
			// 						url: '../setting/setting'
			// 					});
			// 				}
			// 			});
			// 		},
			// 		fail() {
			// 			uni.reLaunch({
			// 				url: '../setting/setting'
			// 			});
			// 		}
			// 	});
			// }, 3000);
		}
	}
};
</script>

<style>
.imgcover {
	width: 750rpx;
	height: 100vh;
}

.imgfull {
	width: 750rpx;
	height: 100vh;
}

.imgfull image {
	width: 750rpx;
	height: 100vh;
}
</style>
